﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using dal;

/// <summary>
///NewsEntity 的摘要说明
/// </summary>
[Serializable]
public class NewsEntity
{
	public NewsEntity()
	{
		
	}

    public NewsEntity(News news)
    {
        this.Author = news.author;
        this.Content = news.content;
        this.Id = news.id;
        this.KeyWord = news.keyword;
        this.PTime = news.ptime;
        this.Source = news.Source;
        this.Stcok = news.Stock;
        this.Title = news.title;
        this.ImageUrl = news.ImageUrl;
    }

    public NewsEntity(long Id)
    {
        var db= DBManager.GetDB();
        var c = db.News.Where(x => x.id == Id && x.IsEnable==true ).First();
        this.Author = c.author;
        this.Content = c.content;
        this.Id = c.id;
        this.KeyWord = c.keyword;
        this.PTime = c.ptime;
        this.Source = c.Source;
        this.Stcok = c.Stock;
        this.Title = c.title;
        this.Summary = c.Summary;
        this.ImageUrl = c.ImageUrl;
    }

    /// <summary>
    /// 主键
    /// </summary>
    public long? Id
    {
        get;
        set;
    }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title
    {
        get;
        set;
    }

    /// <summary>
    /// 发布时间
    /// </summary>
    public DateTime? PTime
    {
        get;
        set;
    }

    public string SPTime
    {
        get
        {
            if(PTime==null)
            {
                return string.Empty;
            }
            else
            {
                return PTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
            }
        }
    }

    /// <summary>
    /// 关键字
    /// </summary>
    public string KeyWord
    {
        get;
        set;
    }

    /// <summary>
    /// 内容
    /// </summary>
    public string Content
    {
        get;
        set;
    }

    /// <summary>
    /// 作者
    /// </summary>
    public string Author
    {
        get;
        set;
    }

    /// <summary>
    /// 相关股票
    /// </summary>
    public string Stcok
    {
        get;
        set;
    }

    /// <summary>
    /// 来源
    /// </summary>
    public string Source
    {
        get;
        set;
    }

    /// <summary>
    /// 摘要
    /// </summary>
    public string Summary
    {
        get;
        set;
    }

    /// <summary>
    /// 外链
    /// </summary>
    public string Url
    {
        get;
        set;
    }

    /// <summary>
    /// 新闻重要度
    /// </summary>
    public int? Step
    {
        get;
        set;
    }

    public string ImageUrl
    {
        get;
        set;
    }


    public int? Nature
    {
        get;
        set;
    }
}